package udf;

import ch.hsr.geohash.GeoHash;
import org.apache.hadoop.hive.ql.exec.UDF;

public class ConvertGeoHash extends UDF {

    public String evaluate(double latitude, double longitude, int numberOfCharacters){
        GeoHash geoHash = GeoHash.withCharacterPrecision(latitude, longitude, numberOfCharacters);
        return geoHash.toBase32();
    }


    public static void main(String[] args) {
        String evaluate = new ConvertGeoHash().evaluate(35.46847397820407, 119.36278007513695, 6);
        System.out.println(evaluate);
    }
}
